package cn.tedu.net.collection.basic;

import java.util.Random;
import java.util.Scanner;

/*
本类用来测试循环结构do while循环
*/
public class Test5_DoWhile {
    public static void main(String[] args) {
        //1.生成一个随机数[0,100)
        int random = new Random().nextInt(100);
        //2.创建do-while死循环用于猜数字
        do {
            System.out.println("猜一个数字");
            int input = new Scanner(System.in).nextInt();
            if (input>random)
                System.out.println("猜大了");
            if (input<random)
                System.out.println("猜小了");
            if(input==random){
                System.out.println("恭喜你猜对了");
                break;//出口 死循环
            }
        }while (1>0);

    }
}
